<script type="text/javascript">
    $(document).ready(function() {    
                
        $("#tags-cities").tokenInput( [
            <c:forEach items="${model.cities}" var="place">
                {id: "<c:out value="${place.id}"/>", name: "<c:out value="${place.title}"/>"},
            </c:forEach>
                {id: 0, name: ""}
            ], {
                theme: "facebook",
                preventDuplicates: true,
                prePopulate: [
                <c:forEach items="${model.place.cities}" var="place">
                    {id: "<c:out value="${place.id}"/>", name: "<c:out value="${place.title}"/>"},
                </c:forEach>
                ]
            }
        );  
        
        $("#tags-districts").tokenInput( [
            <c:forEach items="${model.districts}" var="place">
                {id: "<c:out value="${place.id}"/>", name: "<c:out value="${place.title}"/>"},
            </c:forEach>
                {id: 0, name: ""}
            ], {
                theme: "facebook",
                preventDuplicates: true,
                prePopulate: [
                <c:forEach items="${model.place.districts}" var="place">
                    {id: "<c:out value="${place.id}"/>", name: "<c:out value="${place.title}"/>"},
                </c:forEach>
                ]
            }
        );
        
        $("#tags-buildings").tokenInput( [
            <c:forEach items="${model.buildings}" var="place">
                {id: "<c:out value="${place.id}"/>", name: "<c:out value="${place.title}"/>"},
            </c:forEach>
                {id: 0, name: ""}
            ], {
                theme: "facebook",
                preventDuplicates: true,
                prePopulate: [
                <c:forEach items="${model.place.buildings}" var="place">
                    {id: "<c:out value="${place.id}"/>", name: "<c:out value="${place.title}"/>"},
                </c:forEach>
                ]
            }
        );
        
        $("#tags-villages").tokenInput( [
            <c:forEach items="${model.villages}" var="place">
                {id: "<c:out value="${place.id}"/>", name: "<c:out value="${place.title}"/>"},
            </c:forEach>
                {id: 0, name: ""}
            ], {
                theme: "facebook",
                preventDuplicates: true,
                prePopulate: [
                <c:forEach items="${model.place.villages}" var="place">
                    {id: "<c:out value="${place.id}"/>", name: "<c:out value="${place.title}"/>"},
                </c:forEach>
                ]
            }
        );
        
    });
</script>